package pers.muci.scheduler;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import pers.muci.job.ParamJob;

public class ParamScheduler {
    public static void main(String[] args) throws SchedulerException {
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        JobDetail jobDetail = JobBuilder.newJob(ParamJob.class)
                .withIdentity("paramJob", "group1")
                .usingJobData("msg", "打印日志")
                .build();

        SimpleTrigger trigger = TriggerBuilder.newTrigger()
                //唯一标识
                .withIdentity("paramTrigger", "group1")
                .startNow()
                .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(5))
                .usingJobData("msg", "触发器")
                .build();

        scheduler.scheduleJob(jobDetail, trigger);
        scheduler.start();
    }
}
